<template>
  <!--评论-->
  <div class="comment" style="height: 100%">
    <el-scrollbar height="100%" always>
      <dl v-if="hotComments.length > 0" class="comment-list">
        <!--精彩评论-->
        <dt class="comment-title">精彩评论</dt>
        <dd
          v-for="item in hotComments"
          :key="item.commentId"
          class="comment-item"
        >
          <a
            target="_blank"
            :href="`https://music.163.com/#/user/home?id=${item.user.userId}`"
          >
            <img
              :src="`${item.user.avatarUrl}?param=50y50`"
              class="comment-item-pic"
            />
            <h2 class="comment-item-title">{{ item.user.nickname }}</h2>
          </a>
          <p class="comment-item-disc">{{ item.content }}</p>
          <div class="comment-item-opt">
            <span class="comment-opt-date">{{
              format(item.time, "yyyy年MM月dd")
            }}</span>
            <span class="comment-opt-liked">
              <!-- <mm-icon type="good" /> -->
              <SvgIcon iconName="icon-good" class="good"></SvgIcon>
              {{ item.likedCount }}
            </span>
          </div>
        </dd>
      </dl>
      <!--最新评论-->
      <dl v-if="comments.length > 0" class="comment-list">
        <dt class="comment-title">最新评论（{{ total }}）</dt>
        <dd v-for="item in comments" :key="item.commentId" class="comment-item">
          <a
            class="comment-item-pic"
            target="_blank"
            :href="`https://music.163.com/#/user/home?id=${item.user.userId}`"
          >
            <img
              :src="`${item.user.avatarUrl}?param=50y50`"
              class="cover-img"
            />
          </a>
          <h2 class="comment-item-title">
            <a
              target="_blank"
              :href="`https://music.163.com/#/user/home?id=${item.user.userId}`"
            >
              {{ item.user.nickname }}
            </a>
          </h2>
          <p class="comment-item-disc">{{ item.content }}</p>
          <div
            v-for="beReplied in item.beReplied"
            :key="beReplied.user.userId"
            class="comment-item-replied"
          >
            <a
              target="_blank"
              :href="`https://music.163.com/#/user/home?id=${beReplied.user.userId}`"
            >
              {{ beReplied.user.nickname }}
            </a>
            ：{{ beReplied.content }}
          </div>
          <div class="comment-item-opt">
            <span class="comment-opt-date">{{
              format(item.time, "yyyy年MM月dd")
            }}</span>
            <span v-if="item.likedCount > 0" class="comment-opt-liked">
              <!-- <mm-icon type="good" /> -->
              {{ item.likedCount }}
            </span>
          </div>
        </dd>
      </dl>
    </el-scrollbar>
  </div>
</template>

<script setup>
import { defineProps } from "vue"
import { format } from "date-fns"
defineProps({
  comments: {
    type: Array,
  },
  hotComments: {
    type: Array,
  },
  total: {
    type: Number,
  },
})
</script>

<style lang="less" scoped>
.comment-item-title {
  font-size: 14px;
}
::v-deep .el-scrollbar__bar.is-vertical {
  background-color: #514f4ff7;
  margin-top: 16px;
}
::v-deep .el-scrollbar__thumb {
  background-color: #fff;
}
.comment {
  .comment-list {
    padding: 0 10px;
  }

  .comment-title {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 -10px;
    padding: 10px;
    height: 34px;
    line-height: 34px;
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    margin-right: -2px;
    font-size: 14px;
  }
  .comment-item {
    position: relative;
    padding: 15px 0 15px 55px;
    margin-left: 0px;
    & + .comment-item {
      border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    &-pic {
      display: block;
      position: absolute;
      left: 0;
      top: 20px;
      width: 38px;
      height: 38px;
      border-radius: 50%;
      overflow: hidden;
    }
    &-title {
      height: 20px;
      margin-bottom: 6px;
      font-weight: 400;
      //   .no-wrap();
      color: #fff;
    }
    &-disc {
      overflow: hidden;
      word-break: break-all;
      word-wrap: break-word;
      line-height: 25px;
      text-align: justify;
      font-size: 14px;
      color: rgba(255, 255, 255, 0.6);
      img {
        position: relative;
        vertical-align: middle;
        top: -2px;
      }
    }
    &-replied {
      padding: 8px 19px;
      margin-top: 10px;
      line-height: 20px;
      border: 1px solid rgba(255, 255, 255, 0.3);
      font-size: 14px;
      color: rgba(255, 255, 255, 0.6);
      a {
        color: #fff;
        font-size: 14px;
      }
    }
    &-opt {
      margin-top: 10px;
      line-height: 25px;
      text-align: right;
      overflow: hidden;
      font-size: 14px;
      color: rgba(255, 255, 255, 0.6);
      .comment-opt-date {
        float: left;
        line-height: 28px;
      }
      .comment-opt-liked {
        display: inline-block;
        height: 20px;
        line-height: 20px;
      }
    }
  }
}
</style>
